package com.tangren.controller;

import com.tangren.pojo.test.Stu;
import com.tangren.service.StuService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("u")
@Slf4j

public class HelloController {

    @Autowired
    private StuService stuService;

    @GetMapping("stu")
    public Object stu() {

        Stu stu = new Stu();
//        stu.setId("1001");
        stu.setAge(18);
        stu.setName("慕课网 www.imooc.com");

        stuService.save(stu);

        return "OK";
    }

    @PostMapping("hello")
    public Object hello() {
        Stu stu = new Stu(1001, "imooc", 18);

//        System.out.println(stu.toString());
        log.info("info：" + stu.toString());
        log.debug("debug：" + stu.toString());
        log.warn("warn：" + stu.toString());
        log.error("error：{}", stu.toString());
        return "Hello UserService~~~";
    }
}
